'use strict';

const Controller = require('egg').Controller;

class UploadController extends Controller {
  async show() {
    const { ctx } = this;
    ctx.body = '<form method="post" action="/upload?_csrf=' + ctx.csrf + '" enctype="multipart/form-data">' +
      '<input name="file" type="file" />' +
      '<input type="submit" />' +
      '</form>';
  }

  async xls() {
    const { ctx } = this;
    const file = ctx.request.files[0];
    await ctx.service.upload.xls(file);
    ctx.body = 'Success';
  }
}

module.exports = UploadController;
